<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li {

            list-style: none;
        }

        .ul {
            float: left;
        }

        .ul1 {
            border: 1px solid black;
        }
    </style>
</head>

<body>
    <div>
        <ul class="ul">
            <li>
                <a>1111</a>
                <ul class="ul1">
                    <li>111</li>
                </ul>
            </li>
            <li>
                <a>2222</a>
                <ul class="ul1">
                    <li>2222</li>
                </ul>
            </li>
            <li>
                <a>333</a>
                <ul class="ul1">
                    <li>333</li>
                </ul>
            </li>
        </ul>
    </div>
    <script>
        let num = document.querySelector('ul');
        // let num = sum.children;
        // console.log(num)
        let sum = num.children;
        console.log(sum)
        let flag = 0;
        for (let i = 0; i < sum.length; i++) {
            sum[i].addEventListener('click', function () {
                for (let i = 0; i < sum.length; i++) {
                    if (flag === 0) {
                        console.log(sum[i].parentElement.children[i])
                        // sum[i].parentElement.children[1].style.display = "none";
                        // sum[i].parentElement.children[i].children[1].style.display="none"
                        flag = 1;
                    } else {
                        // sum[i].parentElement.children[1].style.display = "block";
                        flag = 0;
                    }
                    // sum[i].parentElement.children[1].style.display = "block";
                }
            })
        }
    </script>
</body>

</html>